﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Dormsystem
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string user = txtUserName.Text;
            string psw = txtPassword.Text;

            string sql = string.Format("select count(*) from userinfo where username='{0}' and password='{1}' and userstate = '正常';",user,psw);

            int cnt = Convert.ToInt32(DB.GetScalar(sql));

            if (cnt>0)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("输入错误");
            }
            
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}
